package com.sc.nft.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.sc.nft.config.fulu.model.dto.FuLuGoodsInfoDTO;
import com.sc.nft.config.fulu.model.dto.FuLuGoodsTemplateDTO;
import com.sc.nft.config.fulu.model.request.FuLuGoodsInfoRequest;
import com.sc.nft.config.fulu.model.request.FuLuGoodsTemplateRequest;
import com.sc.nft.dao.*;
import com.sc.nft.dto.*;
import com.sc.nft.entity.*;
import com.sc.nft.entity.dto.AttributeDetailDTO;
import com.sc.nft.entity.vo.MallProductVO;
import com.sc.nft.entity.vo.SaasTaskDetailsCollectionVO;
import com.sc.nft.entity.vo.VirtualMallProductSpecsVO;
import com.sc.nft.enums.AllowedShoppingCouponsEnum;
import com.sc.nft.enums.ApprovalStatusEnum;
import com.sc.nft.enums.MallChannelEnum;
import com.sc.nft.enums.ProductTypeEnum;
import com.sc.nft.enums.task.ActivityTypeEnum;
import com.sc.nft.exception.GlobalRunTimeException;
import com.sc.nft.helper.FuLuHelper;
import com.sc.nft.service.MallProductService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * IP商城商品表服务接口实现
 *
 * @author zxy
 * @description IP商城
 * @since 2023-05-10 16:59:01
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class MallProductServiceImpl implements MallProductService {
    private final MallProductDao mallProductDao;
    private final MallCategoryDao mallCategoryDao;
    private final MallProductSpecsDao mallProductSpecsDao;
    private final MallRecommendDao mallRecommendDao;
    private final MallActivityDao activityDao;
    private final MallHotSaleActivityDao mallHotSaleActivityDao;
    private final FuLuHelper fuLuHelper;
    private final MallProductAttributeDao mallProductAttributeDao;


    @Override
    public IPage<ProductPageDTO> getProductPage(Long categoryId, ProductTypeEnum type, ApprovalStatusEnum approvalStatus, Long daoId, String name, Page page, Long supplierId, String supplierName) {
        IPage<ProductPageDTO> productPage = mallProductDao.getProductPage(categoryId, type, approvalStatus, daoId, name, page, supplierId, supplierName);
        productPage.getRecords().forEach(product -> {
            product.setCoverImages(StrUtil.split(product.getCoverImage(), ","));
        });
        return productPage;
    }

    @Override
    public IPage<ProductRecommendDTO> getProductRecommend(ActivityTypeEnum activityType, ProductTypeEnum type, Boolean status, Long daoId, String name, Page page) {
        IPage<ProductRecommendDTO> productRecommend = mallRecommendDao.getProductRecommend(activityType, type, status, daoId, name, page);
        productRecommend.getRecords().forEach(product -> {
            product.setCoverImages(StrUtil.split(product.getCoverImage(), ","));
        });
        return productRecommend;
    }

    public static void main(String[] args) {
        System.out.println(Base64.decodeStr("eyJnb29kc0lkIjowLCJpbnZlbnRvcnlJZCI6MCwibWFpblR5cGUiOjIwMSwib2ZmbGluZVRpbWUiOiIiLCJvbmxpbmVUaW1lIjoiIiwib3JkZXJTbiI6IlAxNjkyNzc5MDc4OTIzMjEwNTgiLCJwcmljZUJvZHkiOltdLCJwcm9kdWN0SWQiOjB9"));
    }


    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addSmartSupplyProduct(String data) {
        JSONArray productArray = JSONArray.parseArray(Base64.decodeStr(data));
        for (int i = 0; i < productArray.size(); i++) {
            JSONObject productInfo = productArray.getJSONObject(i);
            MallProduct product = mallProductDao.getByProductCodeAndChannel(productInfo.getString("id"), MallChannelEnum.SMART);
            if (ObjectUtil.isNull(product)) {
                product = new MallProduct();
                product.setType(ProductTypeEnum.MATERIAL);
                product.setCategoryId(32L);
                product.setDaoId(7L);
                product.setCoverImage(productInfo.getJSONArray("goodsNavigateList").getJSONObject(0).getString("navigateImage"));
                product.setThumbnail(product.getCoverImage());
                product.setProductCode(productInfo.getString("id"));
                product.setProductChannel(MallChannelEnum.SMART);
                product.setProductName(productInfo.getString("name"));
                StringBuffer detail = new StringBuffer();
                for (int j = 0; j < productInfo.getJSONArray("goodsDetailList").size(); j++) {
                    detail.append(productInfo.getJSONArray("goodsDetailList").getJSONObject(j).getString("imagePath"));
                    detail.append(",");
                }
                product.setProductDetail(detail.subSequence(0, detail.length() - 1).toString());
                product.setApprovalStatus(ApprovalStatusEnum.PASS);
                product.insert();
                JSONArray specsArray = productInfo.getJSONArray("products");
                for (int k = 0; k < specsArray.size(); k++) {
                    JSONObject specsInfo = specsArray.getJSONObject(k);
                    MallProductSpecs productSpecs = new MallProductSpecs();
                    productSpecs.setProductId(product.getId());
                    productSpecs.setThumbnail(specsInfo.getString("imagePath"));
                    productSpecs.setSpecsName(specsInfo.getString("specName"));
                    productSpecs.setSpecsCode(specsInfo.getString("id"));
                    JSONObject inventory = specsInfo.getJSONObject("inventory");
                    productSpecs.setInventoryId(inventory.getLong("id"));
                    productSpecs.setCostPrice(inventory.getBigDecimal("taxCooperatePrice").add(inventory.getBigDecimal("defaultFreight")).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP));
                    productSpecs.insert();
                }
            } else {
                log.warn("商品{}已经同步过", productInfo.getString("name"));
            }
        }
    }

    @Override
    public ProductDetailDTO detail(Long id) {
        MallProduct product = mallProductDao.getById(id);
        Assert.notNull(product, () -> new GlobalRunTimeException("商品不存在"));
        ProductDetailDTO detailDTO = new ProductDetailDTO();
        detailDTO.setId(product.getId());
        detailDTO.setDaoId(product.getDaoId());
        detailDTO.setType(product.getType());
        if (product.getCategoryId() != null) {
            MallCategory category = mallCategoryDao.getById(product.getCategoryId());
            Assert.notNull(category, () -> new GlobalRunTimeException("商品分类不存在"));
            detailDTO.setCategoryName(category.getName());
            detailDTO.setCategoryId(category.getId());
        }
        detailDTO.setThumbnail(product.getThumbnail());
        detailDTO.setCoverImage(StrUtil.split(product.getCoverImage(), ","));
        detailDTO.setProductName(product.getProductName());
        detailDTO.setProductCode(product.getProductCode());
        detailDTO.setProductDetail(StrUtil.split(product.getProductDetail(), ","));
        detailDTO.setApprovalStatus(product.getApprovalStatus());
        detailDTO.setRemark(product.getRemark());
        MallProductAttribute mallProductAttribute = mallProductAttributeDao.getById(product.getAttributeId());
        if (!StringUtils.isEmpty(mallProductAttribute) && org.apache.commons.lang3.StringUtils.isNotBlank(mallProductAttribute.getAttributeDetail())) {
            List<AttributeDetailDTO> attributeDetailDTOS = JSONArray.parseArray(mallProductAttribute.getAttributeDetail(), AttributeDetailDTO.class);
            detailDTO.setAttributeName(mallProductAttribute.getAttributeName());
            detailDTO.setAttributeDetailDTOList(attributeDetailDTOS);
        }
        return detailDTO;
    }

    @Override
    public List<MallProductSpecsDTO> productSpecsList(Long productId) {
        MallProduct product = mallProductDao.getById(productId);
        Assert.notNull(product, () -> new GlobalRunTimeException("商品不存在"));
        List<MallProductSpecs> mallProductSpecs = mallProductSpecsDao.productSpecsList(productId);
        return BeanUtil.copyToList(mallProductSpecs, MallProductSpecsDTO.class);
    }

    @Override
    public void approval(Long id, Boolean pass, String approvalRemark) {
        MallProduct product = mallProductDao.getById(id);
        Assert.notNull(product, () -> new GlobalRunTimeException("商品不存在"));
        Assert.isTrue(product.getApprovalStatus() == ApprovalStatusEnum.APPROVAL, () -> new GlobalRunTimeException("商品不是待审核状态"));
        if (pass) {
            product.setApprovalStatus(ApprovalStatusEnum.PASS);
        } else {
            Assert.notBlank(approvalRemark, () -> new GlobalRunTimeException("请填写审核备注"));
            product.setApprovalStatus(ApprovalStatusEnum.REFUSE);
            product.setRemark(approvalRemark);
        }
        product.updateById();

    }

    @Override
    public void allowedShoppingCoupons(Long id, Boolean allowed) {
        MallProduct product = mallProductDao.getById(id);
        Assert.notNull(product, () -> new GlobalRunTimeException("商品不存在"));

        product.setAllowedShoppingCoupons(allowed);

        product.updateById();

    }

    public MallProduct getById(Long productId) {
        return mallProductDao.getById(productId);
    }

    @Override
    public void addRecommend(Long activityId, String recommendWord) {
        MallActivity mallActivity = activityDao.getById(activityId);
        Assert.notNull(mallActivity, () -> new GlobalRunTimeException("活动不存在"));
        Assert.isTrue(mallActivity.getStatus(), () -> new GlobalRunTimeException("活动未上架"));
        MallRecommend recommend = mallRecommendDao.getRecommendByActivityId(activityId);
        Assert.isNull(recommend, () -> new GlobalRunTimeException("活动已推荐"));
        MallRecommend mallRecommend = new MallRecommend();
        mallRecommend.setActivityId(activityId);
        mallRecommend.setRecommendWord(recommendWord);
        mallRecommend.setSort(0);
        mallRecommend.insert();
    }

    /**
     * 批量添加推荐
     *
     * @param activityIds
     */
    @Override
    public void addBatchRecommend(List<Long> activityIds) {
        List<Long> newIds = Lists.newArrayList();
        List<Long> ids = activityDao.getIds(activityIds);
        List<Long> recommendActivityIds = mallRecommendDao.getRecommendByActivityIds(ids);
        if (CollectionUtils.isEmpty(recommendActivityIds)) {
            newIds.addAll(ids);
        } else {
            for (Long id : ids) {
                if (!recommendActivityIds.contains(id)) {
                    newIds.add(id);
                }
            }
        }
        List<MallRecommend> mallRecommends = Lists.newArrayList();
        for (Long newId : newIds) {
            MallRecommend mallRecommend = new MallRecommend();
            mallRecommend.setActivityId(newId);
            mallRecommend.setRecommendWord("");
            mallRecommend.setSort(0);
            mallRecommends.add(mallRecommend);
        }
        mallRecommendDao.saveBatch(mallRecommends);
    }

    @Override
    public void removeRecommend(Long id) {
        MallRecommend recommend = mallRecommendDao.getById(id);
        Assert.notNull(recommend, () -> new GlobalRunTimeException("推荐不存在"));
        recommend.deleteById();
    }

    @Override
    public void setRecommendSort(Long id, Integer sort) {
        MallRecommend recommend = mallRecommendDao.getById(id);
        Assert.notNull(recommend, () -> new GlobalRunTimeException("推荐不存在"));
        recommend.setSort(sort);
        recommend.updateById();
    }

    @Override
    public void setRecommendWord(Long id, String recommendWord) {
        MallRecommend recommend = mallRecommendDao.getById(id);
        Assert.notNull(recommend, () -> new GlobalRunTimeException("推荐不存在"));
        recommend.setRecommendWord(recommendWord);
        recommend.updateById();
    }

    @Override
    public void addHotSaleActivity(Long activityId, String hotSaleImage, String hotSaleTitle, Integer sort) {
        MallActivity mallActivity = activityDao.getById(activityId);
        Assert.notNull(mallActivity, () -> new GlobalRunTimeException("活动不存在"));
        Assert.isTrue(mallActivity.getStatus(), () -> new GlobalRunTimeException("活动未上架"));
        Assert.isNull(mallHotSaleActivityDao.getActivityId(activityId), () -> new GlobalRunTimeException("商品已存在,请勿重复添加"));
        MallHotSaleActivity mallHotSaleActivity = new MallHotSaleActivity();
        mallHotSaleActivity.setDaoId(mallActivity.getDaoId());
        mallHotSaleActivity.setActivityId(activityId);
        mallHotSaleActivity.setHotSaleImage(hotSaleImage);
        mallHotSaleActivity.setHotSaleTitle(hotSaleTitle);
        mallHotSaleActivity.setStatus(Boolean.FALSE);
        mallHotSaleActivity.setSort(sort);
        mallHotSaleActivity.insert();
    }

    @Override
    public void removeHotSaleActivity(Long id) {
        MallHotSaleActivity mallHotSaleActivity = mallHotSaleActivityDao.getById(id);
        Assert.isFalse(mallHotSaleActivity.getStatus(), () -> new GlobalRunTimeException("热卖商品已上架,不能删除"));
        Assert.notNull(mallHotSaleActivity, () -> new GlobalRunTimeException("热卖商品不存在"));
        mallHotSaleActivity.deleteById();
    }

    @Override
    public void setHotSaleSort(Long id, Integer sort) {
        MallHotSaleActivity mallHotSaleActivity = mallHotSaleActivityDao.getById(id);
        Assert.notNull(mallHotSaleActivity, () -> new GlobalRunTimeException("热卖商品不存在"));
        mallHotSaleActivity.setSort(sort);
        mallHotSaleActivity.updateById();
    }

    @Override
    public void setHotSaleStatus(Long id, Boolean status) {
        MallHotSaleActivity mallHotSaleActivity = mallHotSaleActivityDao.getById(id);
        Assert.notNull(mallHotSaleActivity, () -> new GlobalRunTimeException("热卖商品不存在"));
        MallActivity mallActivity = activityDao.getById(mallHotSaleActivity.getActivityId());
        Assert.isTrue(mallActivity.getStatus(), () -> new GlobalRunTimeException("活动未上架,不能设置热卖上架"));
        mallHotSaleActivity.setStatus(status);
        mallHotSaleActivity.updateById();
    }

    @Override
    public IPage<ProductHotSaleDTO> hotSalePage(ActivityTypeEnum activityType, ProductTypeEnum type, Boolean status, Long daoId, String name, Page page) {
        IPage<ProductHotSaleDTO> hotSalePage = mallHotSaleActivityDao.getHotSalePage(activityType, type, status, daoId, name, page);
        hotSalePage.getRecords().forEach(product -> {
            product.setCoverImages(StrUtil.split(product.getCoverImage(), ","));
        });
        return hotSalePage;
    }

    @Override
    public void setCategoryName(Long id, String name) {
        MallCategory category = mallCategoryDao.getById(id);
        Assert.notNull(category, () -> new GlobalRunTimeException("分类不存在"));
        MallCategory byName = mallCategoryDao.getByName(name);
        Assert.isNull(byName, () -> new GlobalRunTimeException("分类名称已存在"));
        category.setName(name);
        category.setModifyTime(DateTime.now());
        category.updateById();
    }

    @Override
    public void setIsBrandUse(Long id, Boolean isBrandUse) {
        MallCategory category = mallCategoryDao.getById(id);
        Assert.notNull(category, () -> new GlobalRunTimeException("分类不存在"));
        category.setIsBrandUse(isBrandUse);
        category.updateById();
    }


    @Override
    public void setIsShow(Long id, Boolean isShow) {
        MallCategory category = mallCategoryDao.getById(id);
        Assert.notNull(category, () -> new GlobalRunTimeException("分类不存在"));
        category.setIsShow(isShow);
        category.updateById();
    }

    @Override
    public void removeCategory(Long id) {
        MallCategory category = mallCategoryDao.getById(id);
        Assert.notNull(category, () -> new GlobalRunTimeException("分类不存在"));
        Integer count = mallProductDao.getCountByCategoryId(id);
        Assert.isFalse(count > 0, () -> new GlobalRunTimeException("分类下存在商品,不能删除"));
        category.deleteById();
    }

    @Override
    public void setIsVirtual(Long id, Boolean isVirtual) {
        MallCategory category = mallCategoryDao.getById(id);
        Assert.notNull(category, () -> new GlobalRunTimeException("分类不存在"));
        category.setIsVirtual(isVirtual);
        category.updateById();
    }

    @Override
    public void setCategorySort(Long id, Integer sort) {
        MallCategory category = mallCategoryDao.getById(id);
        Assert.notNull(category, () -> new GlobalRunTimeException("分类不存在"));
        category.setSort(sort);
        category.setModifyTime(DateTime.now());
        category.updateById();
    }

    /**
     * 热卖商品下架
     *
     * @param activityId
     */
    @Override
    public void offShelf(Long activityId) {
        mallHotSaleActivityDao.updateStatusByActivityId(activityId, false);
    }

    @Override
    public List<MallProduct> simpleList(String productName) {
        return mallProductDao.simpleList(productName);
    }

    /**
     * 添加商品
     *
     * @param mallProductVO
     * @return
     */
    @Override
    public MallProduct addPassProduct(MallProductVO mallProductVO) {
        MallCategory category = mallCategoryDao.getById(mallProductVO.getCategoryId());
        Assert.notNull(category, () -> new GlobalRunTimeException("商品分类不存在"));
        if (ProductTypeEnum.VIRTUAL != mallProductVO.getType()) {
            // 非虚拟商品无法添加
            throw new GlobalRunTimeException("非虚拟商品无法添加");
        }
        return new MallProduct().addPassProduct(mallProductVO.getDaoId(), mallProductVO.getProductName(), StrUtil.join(",", mallProductVO.getCoverImages()), mallProductVO.getThumbnail(), StrUtil.join(",", mallProductVO.getProductDetail()), mallProductVO.getCategoryId(), mallProductVO.getType(), mallProductVO.getIsLongImage(), null);
    }

    /**
     * 编辑商品
     *
     * @param mallProductVO
     * @return
     */
    @Override
    public MallProduct editPassProduct(MallProductVO mallProductVO) {
        Assert.notNull(mallProductVO.getId(), () -> new GlobalRunTimeException("商品Id不得为空"));
        MallProduct product = getById(mallProductVO.getId());
        Assert.notNull(product, () -> new GlobalRunTimeException("未找到商品"));
        if (ProductTypeEnum.VIRTUAL != product.getType()) {
            // 非虚拟商品无法添加
            throw new GlobalRunTimeException("非虚拟商品无法修改");
        }
        Assert.notNull(mallCategoryDao.getById(mallProductVO.getCategoryId()), () -> new GlobalRunTimeException("商品分类不存在"));
        Assert.isFalse(activityDao.checkProductActivity(product.getId()), () -> new GlobalRunTimeException("商品已上架"));
        return product.editPassProduct(mallProductVO.getProductName(), StrUtil.join(",", mallProductVO.getCoverImages()), mallProductVO.getThumbnail(), StrUtil.join(",", mallProductVO.getProductDetail()), mallProductVO.getCategoryId(), mallProductVO.getType(), null);
    }

    @Override
    public void del(Long id) {
        MallProduct product = getById(id);
        Assert.notNull(product, () -> new GlobalRunTimeException("未找到商品"));
        if (ProductTypeEnum.VIRTUAL != product.getType()) {
            // 非虚拟商品无法添加
            throw new GlobalRunTimeException("非虚拟商品无法删除");
        }
        List<MallActivity> mallActivities = activityDao.queryActivityByProductId(id);
        Assert.isTrue(CollUtil.isEmpty(mallActivities), () -> new GlobalRunTimeException("商品正在参与活动，无法删除"));
        product.deleteById();
    }

    /**
     * 添加规格(即添加虚拟商品)
     *
     * @param virtualMallProductSpecsVO
     */
    @Override
    public void addProductSpecs(VirtualMallProductSpecsVO virtualMallProductSpecsVO) {
        MallProduct product = getById(virtualMallProductSpecsVO.getProductId());
        Assert.notNull(product, () -> new GlobalRunTimeException("未找到商品"));
        if (ProductTypeEnum.VIRTUAL != product.getType()) {
            // 非虚拟商品无法添加
            throw new GlobalRunTimeException("非虚拟商品无法添加");
        }
        // api商品ID列表
        List<Integer> apiProductIds = virtualMallProductSpecsVO.getApiProductIds();
        Boolean notHas = mallProductSpecsDao.notHasSpecs(virtualMallProductSpecsVO.getProductId(), apiProductIds);
        Assert.isTrue(notHas, () -> new GlobalRunTimeException("已存在该规格"));
        // 获取虚拟商品详情
        FuLuGoodsInfoRequest fuLuGoodsInfoRequest = new FuLuGoodsInfoRequest();
        FuLuGoodsTemplateRequest fuLuGoodsTemplateRequest = new FuLuGoodsTemplateRequest();
        List<MallProductSpecs> list = Lists.newArrayList();
        for (Integer apiProductId : apiProductIds) {
            fuLuGoodsInfoRequest.setProductId(apiProductId);
            FuLuGoodsInfoDTO fuLuGoodsInfo = fuLuHelper.getFuLuGoodsInfo(fuLuGoodsInfoRequest);
            if (Objects.isNull(fuLuGoodsInfo)) {
                throw new GlobalRunTimeException("未查询到API商品");
            }
            if (StringUtils.isEmpty(fuLuGoodsInfo.getTemplateId())) {
                throw new GlobalRunTimeException("未查询到API商品模版");
            }
            fuLuGoodsTemplateRequest.setTemplateId(fuLuGoodsInfo.getTemplateId());
            FuLuGoodsTemplateDTO fuLuGoodsTemplate = fuLuHelper.getFuLuGoodsTemplate(fuLuGoodsTemplateRequest);
            if (Objects.isNull(fuLuGoodsInfo)) {
                throw new GlobalRunTimeException("未查询到API商品模版");
            }
            MallProductSpecs mallProductSpecs = MallProductSpecs.build(virtualMallProductSpecsVO.getProductId(),
                    fuLuGoodsInfo.getFourCategoryIcon(), fuLuGoodsInfo.getProductName(), BigDecimal.valueOf(fuLuGoodsInfo.getPurchasePrice()),
                    fuLuGoodsInfo.getProductId(), fuLuGoodsInfo.getTemplateId(), fuLuGoodsTemplate.getElementInfo(), fuLuGoodsTemplate.getGameTempaltePreviewList());
            list.add(mallProductSpecs);
        }
        mallProductSpecsDao.saveBatch(list);
    }

    /**
     * 删除规格(即删除虚拟商品)
     *
     * @param productId
     * @param id
     */
    @Override
    public void removeProductSpecs(Long productId, Long id) {
        MallProduct product = getById(productId);
        Assert.notNull(product, () -> new GlobalRunTimeException("未找到商品"));
        if (ProductTypeEnum.VIRTUAL != product.getType()) {
            // 非虚拟商品无法删除
            throw new GlobalRunTimeException("非虚拟商品无法删除");
        }
        Assert.isFalse(activityDao.checkProductActivity(product.getId()), () -> new GlobalRunTimeException("商品已上架"));
        MallProductSpecs productSpecs = mallProductSpecsDao.getById(id);
        productSpecs.deleteById();
    }

    @Override
    public void editProductSpecs(Long productId, Long specsId, String name) {
        MallProduct product = getById(productId);
        Assert.notNull(product, () -> new GlobalRunTimeException("未找到商品"));
        if (ProductTypeEnum.VIRTUAL != product.getType()) {
            // 非虚拟商品无法删除
            throw new GlobalRunTimeException("非虚拟商品修改规格名称");
        }
        MallProductSpecs productSpecs = mallProductSpecsDao.getById(specsId);
        Assert.notNull(productSpecs, () -> new GlobalRunTimeException("该规格不存在"));
        Assert.isFalse(activityDao.checkProductActivity(product.getId()), () -> new GlobalRunTimeException("商品已上架"));
        productSpecs.setSpecsName(name);
        productSpecs.updateById();
    }

    /**
     * 根据ids获取对应的藏品信息
     *
     * @param ids
     * @return
     */
    @Override
    public List<SaasTaskDetailsCollectionVO> getMallProductSimplenessByIds(List<Long> ids) {
        return mallProductDao.getMallProductSimplenessByIds(ids);
    }
}